#!/usr/bin/env bash

set -e

. ./scripts/version
cd $(dirname $0)/..

if [ "${CHART_REPO}" = "latest" ]; then
    echo "error: can not promote from 'latest' to 'latest'"
    exit 1
fi

curl -f -H 'Cache-Control: max-age=0,no-cache' -H 'Host: releases.rancher.com' "https://c.storage.googleapis.com/server-charts/latest/rancher-${CHART_VERSION}.tgz?$(date +%s%N)" -o ./charts/stable/rancher-${CHART_VERSION}.tgz

./scripts/get_and_merge_index ${CHART_REPO}
